package main

import (
	"fmt"
	"time"
)

type TaskFunc func()

func test() {
	time.Sleep(3 * time.Second)
	print("test")
}

func custome(ch <-chan TaskFunc) {
	for task := range ch {
		task() // 调用闭包中的函数来执行任务
	}
}

func main() {
	a := make(chan TaskFunc, 2)
	go custome(a)
	a <- func() {
		test()
	}
	a <- func() {
		test()
	}
	print("main")
	var b string
	fmt.Scan(&b)
}
